package cn.yunhe.servlet;

import cn.yunhe.dao.ITypeDaoMapper;
import cn.yunhe.entity.merchantsentity.Type;
import cn.yunhe.services.AddTypeService;
import cn.yunhe.services.TypeServiceZhou;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


@WebServlet("/shangjia/AddTypeServlet")
public class AddTypeServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String type = request.getParameter("product-category-name");
            Type type1 = new Type();
            type1.setType(type);
        AddTypeService addTypeService = new AddTypeService();

        response.setContentType("test/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
            if (addTypeService.addType(type1)>0){
                out.print("<script>alert('添加成功');</script>");
            }



    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
